// 使 v-focus 在所有组件中都可用
// Vue.directive('imgError', {
export default {
  // 当被绑定的元素插入到 DOM 中时....
  inserted: function (el, binding) {
    // el.addEventListener('load'，function () {
    // console.log('img加载成功')
    // })
    // 监听图片是否加载失败 ! ! !!
    el.addEventListener('error', function () {
      console.log('img加载失败')
      // 把img替换成默认图片（）
      // el.src = 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2F23dafd46-47c4-4f03-bab5-23152cc816d4%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1681373198&t=98ea9a8998b04adb3dc78ccc877c7aa1'

      el.src = binding.value
    })
    console.log(el)
  }
}
// })
